// 引入vue
import Vue from 'vue'

// 引入插件
import VueRouter from 'vue-router'

// 引入路由组件
import Login from '../pages/Login'
import Home from '../pages/Home'
import Music from '../pages/Home/Music'
import News from '../pages/Home/News'
import Game from '../pages/Home/Game'

// 
Vue.use(VueRouter)

export default new VueRouter({
    routes: [{
            path: '/login',
            component: Login
        },
        {
            path: '/home',
            component: Home,
            // 在某个路由规则中如果有默认子路由,则在当前路由中不再书写name属性
            // name:'home',
            // 二级路由
            children:[
                // params传参 :time? --- 可选
                {path:'music/:id/:time?',component:Music ,name:'a'},
                {path:'news',component:News, name:'b'},
                // 二级重定向-1
                // {path:'/',redirect:'/home/music'}
                // 二级重定向-2.默认子路由
                // {path:'',component:Music},
                {path:'game',component:Game}
            ]
        },
        // redirect 重定向，跳转到指定路由
        {path:'/',redirect:'/home'}
    ]
})